﻿<ResourceDictionary 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:Controls="clr-namespace:iPhone.Controls">

    <Style TargetType="{x:Type Controls:BusyIndicator}">
        <Style.Triggers>
            <Trigger Property="IsEnabled" Value="True">
                <Setter Property="Height" Value="Auto"/>
            </Trigger>
        </Style.Triggers>

        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="Controls:BusyIndicator">
                    <Grid>
                        <Border Background="Black" Opacity="0.5" Padding="7"  />
                        <DockPanel HorizontalAlignment="Center" VerticalAlignment="Center">
                            <Grid>
                                <Ellipse Fill="#FF1B6EE4" Width="68" Height="68">
                                    <Ellipse.Effect>
                                        <DropShadowEffect Color="White" ShadowDepth="0" BlurRadius="10"/>
                                    </Ellipse.Effect>
                                    <Ellipse.OpacityMask>
                                        <RadialGradientBrush>
                                            <GradientStop Color="#00000000" Offset="0.625"/>
                                            <GradientStop Offset="1"/>
                                            <GradientStop Color="Black" Offset="0.672"/>
                                            <GradientStop Color="Black" Offset="0.944"/>
                                        </RadialGradientBrush>
                                    </Ellipse.OpacityMask>
                                </Ellipse>
                                <Ellipse Width="70" Height="70">
                                    <Ellipse.Fill>
                                        <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                            <GradientStop Color="#FF497BAB" Offset="1"/>
                                            <GradientStop Color="#FF5EAFFF"/>
                                            <GradientStop Color="#FF1762AD" Offset="0.403"/>
                                        </LinearGradientBrush>
                                    </Ellipse.Fill>
                                    <Ellipse.OpacityMask>
                                        <RadialGradientBrush>
                                            <GradientStop Color="#00000000" Offset="0.625"/>
                                            <GradientStop Offset="1"/>
                                            <GradientStop Color="Black" Offset="0.672"/>
                                            <GradientStop Color="Black" Offset="0.944"/>
                                        </RadialGradientBrush>
                                    </Ellipse.OpacityMask>
                                </Ellipse>
                                <Ellipse x:Name="ellipse" Width="70" Height="70" RenderTransformOrigin="0.5,0.5">
                                    <Ellipse.OpacityMask>
                                        <RadialGradientBrush>
                                            <GradientStop Color="#00000000" Offset="0.625"/>
                                            <GradientStop Offset="1"/>
                                            <GradientStop Color="Black" Offset="0.672"/>
                                            <GradientStop Color="Black" Offset="0.944"/>
                                        </RadialGradientBrush>
                                    </Ellipse.OpacityMask>
                                    <Ellipse.RenderTransform>
                                        <TransformGroup>
                                            <ScaleTransform/>
                                            <SkewTransform/>
                                            <RotateTransform/>
                                            <TranslateTransform/>
                                        </TransformGroup>
                                    </Ellipse.RenderTransform>
                                    <Ellipse.Fill>
                                        <RadialGradientBrush GradientOrigin="0.9,0.794" RadiusX="0.286" RadiusY="0.307" Center="0.742,0.659">
                                            <GradientStop Offset="0.621"/>
                                            <GradientStop Color="#70FFFFFF" Offset="0.198"/>
                                        </RadialGradientBrush>
                                    </Ellipse.Fill>
                                </Ellipse>
                            </Grid>
                        </DockPanel>
                    </Grid>

                    <ControlTemplate.Triggers>
                        <Trigger Property="IsBusy" Value="True">
                            <Setter Property="Visibility" Value="Visible" /> 
                            <Trigger.EnterActions>
                                <BeginStoryboard Name="BeginBusyIndicator">
                                    <Storyboard RepeatBehavior="Forever">
                                        <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="ellipse" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[2].(RotateTransform.Angle)">
                                            <SplineDoubleKeyFrame KeyTime="00:00:00" Value="720"/>
                                            <SplineDoubleKeyFrame KeyTime="00:00:00.7000000" Value="900"/>
                                            <SplineDoubleKeyFrame KeyTime="00:00:01.4000000" Value="1080"/>
                                        </DoubleAnimationUsingKeyFrames>
                                    </Storyboard>
                                </BeginStoryboard>
                            </Trigger.EnterActions>
                            <Trigger.ExitActions>
                                <StopStoryboard BeginStoryboardName="BeginBusyIndicator"/>
                            </Trigger.ExitActions>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="Height" Value="0" />
        <Setter Property="Visibility" Value="Collapsed" />
    </Style>

</ResourceDictionary>